package com.pf.publish_subscribe.common;

import com.pf.publish_subscribe.config.PublishSubScribeConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 * 发布者
 */
@Component
public class RedisPubliscer {

    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 发布消息
     */
    public void publish() {
        String message = "hello redis...";
        redisTemplate.convertAndSend(PublishSubScribeConfig.CHANNEL, message);
    }
}
